package demo.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.data.mongodb.MongoDbFactory;
import org.springframework.data.mongodb.core.MongoTemplate;
//import org.springframework.data.mongodb.core.SimpleMongoDbFactory;

//import com.mongodb.MongoClientURI;

//@Configuration
public class MongoConfig {

    @Value("${mongodb.galaxy.uri}")
    private String galaxyUri;

    @Value("${mongodb.lake.uri}")
    private String lakeUri;

//    @Primary
//    @Bean(name = "lakeMongoTemplate")
//    public MongoTemplate lakeMongoTemplate() {
//        MongoDbFactory mongoDbFactory = new SimpleMongoDbFactory(new MongoClientURI(lakeUri));
//        return new MongoTemplate(mongoDbFactory);
//    }

//    @Bean(name = "galaxyMongoTemplate")
//    public MongoTemplate galaxyMongoTemplate() {
//        MongoDbFactory mongoDbFactory = new SimpleMongoDbFactory(new MongoClientURI(galaxyUri));
//        return new MongoTemplate(mongoDbFactory);
//    }

    // spring boot 请在properties里边使用uri方式进行连接
    // spring.data.mongodb.uri=mongodb://username:password@mongoserver1:34001,mongoserver2:34001,mongoserver3:34001/dbname?AutoConnectRetry=true
    // spring.data.mongodb.repositories.enabled=true

}
